<?php
namespace app\index\controller;
use app\index\model\Api;
use think\Controller;
use app\admin\model\ApiGroup as ApiGroupModel;

class Common extends Controller
{
    public function allGroupAndApiList()
    {
        //$list = ApiGroupModel::all(['status'=>1]);
        $model = new ApiGroupModel();

        $list = $model->alias('g')->join('api a','a.group_id = g.id')->where(['g.status'=>1,'a.status'=>1])->field('g.id,g.name')->select();

        /*foreach($list as $k => &$v){
            $v->api = Api::all(['group_id'=>$v->id,'status'=>1]);
            if(!isset($v->api) || empty($v->api)){
                unset($list[$k]);
            }
        }*/
        //logs($list);
        return ajaxReturn($list);
    }
}
